//
//  LOLScrollView.m
//  LOLNews
//
//  Created by MXL on 16/10/28.
//  Copyright © 2016年 KK. All rights reserved.
//

#import "LOLScrollView.h"

static NSString *cellID = @"cellID";

@interface LOLScrollView ()<UITableViewDataSource>
@property (nonatomic,weak)UITableView *friendTable;

@property (nonatomic,weak)UITableView *newsTable;

@end

@implementation LOLScrollView

- (instancetype)init{
    if (self = [super init]) {
        [self setupUI];
    }
    return self;
}

#pragma mark - 界面
- (void)setupUI{
    
    self.backgroundColor = [UIColor blueColor];
    
    UITableView *friendTable = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStylePlain];
    
    UITableView *newsTable = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStylePlain];
    
    // 注册cell
    [friendTable registerClass:[UITableViewCell class] forCellReuseIdentifier:cellID];
    
    [newsTable registerClass:[UITableViewCell class] forCellReuseIdentifier:cellID];
    
    // 代理与数据源
    friendTable.dataSource = self;
    newsTable.dataSource = self;
//    friendTable.delegate = self;
//    newsTable.delegate = self;
    
    // 颜色
    friendTable.backgroundColor = [UIColor colorWithRed:1.000 green:0.977 blue:0.244 alpha:1.000];
    newsTable.backgroundColor = [UIColor colorWithRed:0.284 green:1.000 blue:0.549 alpha:1.000];

    [self addSubview:friendTable];
    [self addSubview:newsTable];
    
    
    
    
    // 记录
    self.friendTable = friendTable;
    self.newsTable = newsTable;
    
    // 约束
    [self.friendTable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.equalTo(self);
        make.top.left.equalTo(self);
    }];
    //        self.friendTable.frame = self.bounds;
    [self.newsTable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.equalTo(self);
        make.left.equalTo(self.friendTable.mas_right);
        make.top.equalTo(self);
    }];
    
    
    
}

- (void)layoutSubviews{
    if (self.frame.size.width) {
        self.contentSize = CGSizeMake(self.bounds.size.width*2, 0);
    }
}

#pragma mark - UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 10;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID forIndexPath:indexPath];
    
    cell.textLabel.text = @(indexPath.row).description;
    
    
    
    return cell;
}

@end
